﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using DotConferenceSql;
using NUnit.Framework.SyntaxHelpers;

namespace TestDotConferenceSql
{
    [TestFixture]
    public class TestDeleteQueryElement
    {
        SqlQuery query;
        DeleteFromQueryElement deleteElement;

        [SetUp]
        public void Init()
        {
            query = new SqlQuery();
            deleteElement = new DeleteFromQueryElement("Test");
        }

        [Test]
        public void BasicDeleteQuery()
        {
            query.Elements.Add(deleteElement);

            Assert.That(query.BuildTextQuery(), Text.Contains("DELETE FROM Test"));
        }

        [Test]
        public void DeleteQueryWithCondition()
        {
            query.Elements.Add(deleteElement);

            WhereClauseQueryElement whereElement = new WhereClauseQueryElement();
            whereElement.Elements.Add(new CustomWhereStatement("field1 = 1"));

            query.Elements.Add(whereElement);

            Assert.That(query.BuildTextQuery(), Text.Contains("DELETE FROM Test WHERE field1 = 1"));
        }
    }
}
